#include "epoll.h"
#include "head.h"


int epollAddReadEvent(int epoll_fd, int fd){
    
    struct epoll_event event;
    event.data.fd = fd;
    event.events = EPOLLIN;
    int ret = epoll_ctl(epoll_fd, EPOLL_CTL_ADD, fd, &event);
    printf("Epollin is adding...\n");
    ERROR_CHECK(ret, -1, "epoll_ctl");

    return 0;
}
int epollAddWriteEvent(int epoll_fd,int fd)
{
    struct epoll_event event;
    event.data.fd = fd;
    event.events = EPOLLOUT;
    int ret = epoll_ctl(epoll_fd, EPOLL_CTL_ADD, fd, &event);
    printf("Epollin is adding...\n");
    ERROR_CHECK(ret, -1, "epoll_ctl");

    return 0;
}

int epollDeleteReadEvent(int epoll_fd, int fd)
{
    struct epoll_event event;
    event.data.fd = fd;
    event.events = EPOLLIN;
    int ret = epoll_ctl(epoll_fd, EPOLL_CTL_DEL, fd, &event);
    printf("Epollin is deleting...\n");
    ERROR_CHECK(ret, -1, "epoll_ctl");

    return 0;

}
int epolDeleteWriteEvent(int epoll_fd, int fd){

    struct epoll_event event;
    event.data.fd = fd;
    event.events = EPOLLOUT;
    int ret = epoll_ctl(epoll_fd, EPOLL_CTL_DEL, fd, &event);
    printf("Epollin is deleting...\n");
    ERROR_CHECK(ret, -1, "epoll_ctl");

    return 0;
}

